<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>案例</title>
    <style>
        .one{
            width: 200px;
            height: 200px;
            float: left;
            background-color: red;
        }
        .two{
            width: 200px;
            height: 200px;
            float: left;
            background-color: green;
        }
        .three{
            width: 200px;
            height: 200px;
            float: left;
            background-color: purple;
        }
    </style>
</head>
<body>
    <div id="root">
        <button>按钮</button>
        <hr>
        <div class="one"></div>
        <div class="two"></div>
        <div class="three"></div>
    </div>
    <script>
        // 1、获取元素
        var one = document.getElementsByClassName('one')[0];
        var two = document.getElementsByClassName('two')[0];
        var three = document.getElementsByClassName('three')[0];
        var button = document.getElementsByTagName('button')[0];
        // 2、绑定事件
        button.onclick = function(){
            one.style.display = 'none';
            three.style.display = 'none';
        }
    </script>
</body>
</html>